package com.lesama.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        // 1.创建Socket对象
        Socket socket = new Socket("127.0.0.1", 8989);

        // 获取到服务端的输入输出流
        InputStream inputStream = socket.getInputStream();
        OutputStream outputStream = socket.getOutputStream();

        outputStream.write("summer pockets".getBytes());

        byte[] bytes = new byte[1024];
        int len = inputStream.read(bytes);

        System.out.println(new String(bytes, 0, len));

        socket.close();
    }
}